/*
    Copyright (c) 2001-2002 BSQUARE Corporation.  All rights reserved.

	Generic help command
*/

#include "includes.h"


const char helpHelp[] = 
    "Syntax help <cmd>\r\n\
   \tcmd - show help text for command <cmd>\r\n";

const char PwmHelp[] = 
    "Syntax pwmset <Percentage>\r\n\
   \tExamples1: pwmset 100  100% on\r\n \
   \tExamples2: pwmset 0    off \r\n";



int
Help(int argc, char *argv[])
{
    int CmdNum=0;
    int argNum=1;
    const char *ptr;
    

    if (1==argc) {
        CLIOutputString(helpHelp);
        
        //
        // List cmds
        //
        while(NULL != (ptr=GetCmdName(CmdNum++))) {
            CLIOutputString("%s\r\n",ptr);
        } 
    }
    
    //
    //  Search command list for all cmds on CL
    //
    while (argc > argNum) {
        
        CmdNum = SearchForCmd(argv[argNum++]);
        if (ERROR_NOTFOUND != CmdNum) {
            //
            // Disply help string
            //
            CLIOutputString("%s", GetCmdHelpText(CmdNum));
        }        
    }
    
return ERROR_SUCCESS;	
}

int
Pwmset(int argc, char *argv[])
{
    uint32 Feg;
    

    if (argc < 2) {
        return ERROR_MISSINGARGS;        
              
    }
    
    if (!strtohex(argv[1], (unsigned int *)&Feg)) {
       return ERROR_MISSINGARGS;
    }
    SetPwm(Feg);
    
return ERROR_SUCCESS;	
}